package com.bigevent.mapper;

import com.bigevent.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    @Select("select * from user where username = #{username}")
    User findByUserName(String username);

    @Insert("insert into user(username,password,create_time,update_time,authority) values(#{username},#{password},#{date},#{date},#{authority})")
    void register(String username, String password, LocalDateTime date,String authority);

    @Update("update user set nickname = #{nickname},email = #{email},update_time = #{updateTime} where id = #{id}")
    void update(User user);

    @Update("update user set user_pic = #{userPic},update_time = #{date} where id = #{id}")
    void updateUserPic(String userPic, Integer id, LocalDateTime date);

    @Insert("update user set password = #{passWord},update_time = #{date},create_time = #{date}  where id = #{id}")
    void updateUserPwd(String passWord, Integer id, LocalDateTime date);
}
